#include <iostream>
#include <vector>
using namespace std;

void solve() {
    int l, n;
    cin >> l >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans1 = 0, ans2 = 0;
    for(int i = 0; i < n; i++) {
        ans1 = max(ans1, min(a[i], l - a[i]));
        ans2 = max(ans2, max(a[i], l - a[i]));
    }
    cout << ans1 << ' ' << ans2 << endl;
}

int main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}